#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,vmax;
struct car{
    int fr,s,a;
}c[200005];
int f[200005],ans1;
pair<int,int> qu[200005];// the first is the end of the qu
void find_between(int id,int fr,int bs,int as){
    int sp=lower_bound(f+1,f+1+m,fr)-f;
    if(sp==m+1){
        qu[id].first=qu[id].second=0;
        ans1++;
        return ;
    }
    if(as==0&&bs<=vmax){ qu[id].first=qu[id].second=0;ans1++;}
    if(as==0&&bs>vmax) qu[id].first=n,qu[id].second=sp;
    int l=sp,r=m;
    if(as>0){
        if(sqrt(bs*bs+2*as*(f[m]-fr))<=vmax) ans1++;
        if(bs>vmax){
            qu[id].first=m,qu[id].second=sp;
            return;
        }
        while(l<=r){
            int mid=l+r>>1;
            if(sqrt(bs*bs+2*as*(f[mid]-fr))>vmax) r=mid-1;
            else l=mid+1;
        }
        qu[id].first=m,qu[id].second=l;
        if(l==m+1){
            qu[id].first=qu[id].second=0;
           // ans1++;
        }
    }
    if(as<0){
        int absdf;
        if((vmax*vmax-bs*bs)/(2*as)==float((vmax*vmax-bs*bs))/(2*as))absdf=(vmax*vmax-bs*bs)/(2*as);
        else absdf=(vmax*vmax-bs*bs)/(2*as)+1;
        if(bs<=vmax||absdf<=f[sp]-fr){
            ans1++;
        }
        if(sqrt(bs*bs+2*as*(f[sp]-fr))<=vmax){
            qu[id].first=qu[id].second=0;
        //    ans1++;
        }
        int ep=upper_bound(f+sp,f+1+m,fr+(-bs*bs)/(2*as))-f-1;
        if(ep<sp){
            qu[id].first=qu[id].second=0;
         //   ans1++;
        }
        r=ep;
      //  if(id==5) cout<<sp<<'!'<<ep<<endl;
        while(l<=r){
            int mid=l+r>>1;
            if(sqrt(bs*bs+2*as*(f[mid]-fr))>vmax) l=mid+1;
            else r=mid-1;
        }
        qu[id].first=r,qu[id].second=sp;
        if(r==sp-1){
         //   ans1++;
            qu[id].first=qu[id].second=0;
        }
    }
}
void solve(){
    ans1=0;
    cin>>n>>m>>l>>vmax;
    for(int i=1;i<=n;i++) cin>>c[i].fr>>c[i].s>>c[i].a;
    for(int i=1;i<=m;i++) cin>>f[i];
    for(int i=1;i<=n;i++){
        find_between(i,c[i].fr,c[i].s,c[i].a);
    }
    sort(qu+1,qu+1+n);
    //for(int i=1;i<=n;i++) cout<<qu[i].second<<" "<<qu[i].first<<"?"<<endl;
    cout<<n-ans1<<' ';
    int flag=1,ans=-1,choose=-1;
    for(int i=0;i<=n;i++){
        if(choose<qu[i].second){
            ans++,choose=qu[i].first;
        }
    }
    cout<<m-ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
    while(t--) solve();
    fclose(stdin);
    fclose(stdout);
	return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
